﻿using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace ClockInLearning
{   
    // 定时服务样例
    public class BackgroundTaskService : BackgroundService
    {
        public BackgroundTaskService() { }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    // 执行方法
                }
                catch (Exception ex)
                {
                }

                // 定时时间
                await Task.Delay(1000 * 60 * 5, stoppingToken);
            }
        }
    }
}
